package cn.gbase.jiangsu.data.transfer.util;

import java.text.SimpleDateFormat;
import java.util.Date;

//日期转换
public class DateUtil {

	//date转str
	public static String toString(Date date, String pattern) {
		SimpleDateFormat format = new SimpleDateFormat(pattern);
		return format.format(date);
	}

	//str转date
	public static Date toDate(String date, String pattern) {
		SimpleDateFormat format = new SimpleDateFormat(pattern);
		try {
			return format.parse(date);
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
}
